﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pipe : MonoBehaviour {

    public void Start()
    {
        RandomGeneratePosition();
    }


    public void RandomGeneratePosition()
    {
        float pos_y = Random.Range(-0.4f, -0.1f);
        transform.localPosition = new Vector3(transform.localPosition.x, pos_y, transform.localPosition.z);
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.tag == "Player")
        {
            GameManager.instance.score++;
        }
    }
    private void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.tag == "Player")
        {
            GameManager.instance.GameState = GameManager.GAMRSTATE_END;
        }
    }

    private void OnGUI()
    {
        GUILayout.Label("Score:" + GameManager.instance.score);
    }

}
